package com.miniapp.web.controller.miniapp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.miniapp.core.domain.TMiniAgentGen;
import com.miniapp.core.service.ITMiniAgentGenService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.miniapp.common.annotation.Log;
import com.miniapp.common.core.controller.BaseController;
import com.miniapp.common.core.domain.AjaxResult;
import com.miniapp.common.enums.BusinessType;

import com.miniapp.common.utils.poi.ExcelUtil;
import com.miniapp.common.core.page.TableDataInfo;

/**
 * 代理人功能Controller
 *
 * @author miniapp
 * @date 2024-12-01
 */
@RestController
@RequestMapping("/basics/miniagent")
public class TMiniAgentGenController extends BaseController
{
    @Autowired
    private ITMiniAgentGenService tMiniAgentGenService;

    /**
     * 查询代理人功能列表
     */
    @PreAuthorize("@ss.hasPermi('basics:miniagent:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMiniAgentGen tMiniAgentGen)
    {
        startPage();
        List<TMiniAgentGen> list = tMiniAgentGenService.selectTMiniAgentGenList(tMiniAgentGen);
        return getDataTable(list);
    }

    /**
     * 导出代理人功能列表
     */
    @PreAuthorize("@ss.hasPermi('basics:miniagent:export')")
    @Log(title = "代理人功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMiniAgentGen tMiniAgentGen)
    {
        List<TMiniAgentGen> list = tMiniAgentGenService.selectTMiniAgentGenList(tMiniAgentGen);
        ExcelUtil<TMiniAgentGen> util = new ExcelUtil<TMiniAgentGen>(TMiniAgentGen.class);
        util.exportExcel(response, list, "代理人功能数据");
    }

    /**
     * 获取代理人功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('basics:miniagent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tMiniAgentGenService.selectTMiniAgentGenById(id));
    }

    /**
     * 新增代理人功能
     */
    @PreAuthorize("@ss.hasPermi('basics:miniagent:add')")
    @Log(title = "代理人功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMiniAgentGen tMiniAgentGen)
    {
        return toAjax(tMiniAgentGenService.insertTMiniAgentGen(tMiniAgentGen));
    }

    /**
     * 修改代理人功能
     */
    @PreAuthorize("@ss.hasPermi('basics:miniagent:edit')")
    @Log(title = "代理人功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMiniAgentGen tMiniAgentGen)
    {
        return toAjax(tMiniAgentGenService.updateTMiniAgentGen(tMiniAgentGen));
    }

    /**
     * 删除代理人功能
     */
    @PreAuthorize("@ss.hasPermi('basics:miniagent:remove')")
    @Log(title = "代理人功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMiniAgentGenService.deleteTMiniAgentGenByIds(ids));
    }
}
